<?php
require_once ("src/db/connectdatabase.php");

function loadCompareCardDetail($arrcompare) {
	$con = new ConnectDB();
	
	$sql = "SELECT carddetailid, bankid, bankname, banklogo, cardlimit, cardtypename, cardtypelogo, cardlevelname, balancetransfer, monthstransfer, interestrate, annualfee, interestfreedays, latepaymentfee, minimumrepayment, phiruttien, areaofcards, linkgotosite FROM carddetail WHERE carddetailid IN (".$arrcompare.")";
	return $con -> getvalueString($sql);
}
if(isset($_SESSION['arrcomparecarddetail'])) {
	$arrcompare = $_SESSION['arrcomparecarddetail'];
	$temp = "";
	for($i = 0; $i < count($arrcompare); $i++) {
		if($i == count($arrcompare)-1) {
			$temp .= $arrcompare[$i];
		} else {
			$temp .= $arrcompare[$i].',';
		}
	}
	$arrresultcompare = loadCompareCardDetail($temp);
?>
<style>
.class-content-result-loading {
	position: fixed;
	height: 100%;
	width: 100%;
	background: #000;
	background: rgba(0,0,0,.8);
	z-index: 100;
	top: 0;
	left: 0;
	display: none;
}

.spanmarringleft {
	margin-left: 13px;
}

.colorbg {
	background: #F1F1F1;
}

.class-detail-title {
	width: 150px;
	font-weight: bold;
}

.compare-title {
	float: left;
	margin-left: 3px;
}

.product-details {
	float: left;
	margin-left: 3px;
}

dt, dd {
	float: left;
	height: 40px;
	line-height: 40px;
}

dd {
	width: 200px;
	text-align: center;
	font-weight: bold;
	color: rgb(51, 51, 51);
	overflow: hidden;
}

.listwrapper {
	display: block;
	height: 350px;
	left: 123px;
	overflow-y: hidden;
	width: 865px;
}

.company {
	text-align: center;
	margin-bottom: 5px;
	line-height: 18px;
	padding: 5px 0px 10px;
	background-color: rgb(200, 225, 255);
	min-height: 40px;
	position: relative;
	border-radius: 5px 5px 5px 5px;
	box-shadow: 0px 1px 0px rgb(204, 204, 204);
	width: 200px;
	float: left;
	margin-left: 3px;
}

ol.productlist {
	margin-left: -76px;
	width: 865px;
	height: 350px;
	position: absolute;
	margin: 0px -76 auto;
}

ol li {
	float: left;
	list-style-type: none;	
}

.closeproduct {
	background-position: 0px -45px;
	height: 20px;
	position: absolute;
	right: 5px;
	top: 2px;
	width: 12px;
	cursor: pointer;
	background: url("<?php echo($host) ?>images/baseg.png") no-repeat scroll 0px 0px transparent;
}
</style>
<div class="class-content-result-loading"></div>
<div class="text12" style="margin: auto; width: 970px; height: 11px; margin-top: 11px; color: #0a8bd9;">
	<u><a href="<?php echo($host) ?>" class="text12" style="color: #0080d6;">Trang Chủ</a></u>&gt; <a href="#" class="text12" style="color: #4c4c4c;">So Sánh Dịch Vụ Cho Vay</a></span>
</div>
<div style="clear:both; height:15px;"></div>
<div style="width: 980px; clear: right;" class="class-content-company">
    <div style=" float:left; width:150px; margin-left:3px; height: 40px; text-align:center; padding-top: 20px;"></div>
    <!--<div class="company">
    	<span>
        	Name  Bank <br /> Loai hinh vay
        </span>
    	<a class="closeproduct" title="Xóa" value="123"></a>
    </div>-->
</div>
<div style="clear:both;"></div>
<div style="width: 980px; font-size:12px;">
	<div style="width: 150px; float:left;">
        <dl class="compare-title" style="width: 150px;">
            <dt class="class-detail-title"><span class="spanmarringleft">Ngân Hàng</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Hạn Mức Thẻ</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Loại Thẻ</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Loại Thẻ</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Chuyển Khoản Số Dư</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Lãi Xuất</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Lệ Phí Hằng Năm</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Số Ngày Miễn Phí</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Phí Chậm Thanh Toán</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Trả Nợ Tối Thiểu</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Phí Rút Tiền Mặt</span></dt>
            <dt class="class-detail-title colorbg"><span class="spanmarringleft">Khu Vực Cấp Thẻ</span></dt>
            <dt class="class-detail-title"><span class="spanmarringleft">Liên Kết</span></dt>
        </dl>
    </div>
    <div class="listwrapper" style="width: 830px; float:left;">
    	<ol class="productlist">
            <!--<li id="product_342342">
            	<dl class="product-details" style="width: 200px;">
                    <dd><img src="images/logobanks/1369639988.jpg" height="36px" /></dd>
                    <dd class="colorbg">10.000.000</dd>
                    <dd><img src="images/logobanks/1369639988.jpg" height="36px" /></dd>
                    <dd class="colorbg">Visa</dd>
                    <dd>so du</dd>
                    <dd class="colorbg">lai xuat</dd>
                    <dd>phi nam</dd>
                    <dd class="colorbg">ngay free</dd>
                    <dd>phi cham tt</dd>
                    <dd class="colorbg">toi thieu</dd>
                    <dd>Có Phí</dd>
                    <dd class="colorbg">Miền Trung</dd>
                    <dd>lien ket</dd>
                </dl>
            </li>
            <li id="product_342342">
            	<dl class="product-details" style="width: 200px;">
                    <dd><img src="images/logobanks/1369639988.jpg" height="36px" /></dd>
                    <dd class="colorbg">10.000.000</dd>
                    <dd><img src="images/logobanks/1369639988.jpg" height="36px" /></dd>
                    <dd class="colorbg">Visa</dd>
                    <dd>so du</dd>
                    <dd class="colorbg">lai xuat</dd>
                    <dd>phi nam</dd>
                    <dd class="colorbg">ngay free</dd>
                    <dd>phi cham tt</dd>
                    <dd class="colorbg">toi thieu</dd>
                    <dd>Có Phí</dd>
                    <dd class="colorbg">Miền Trung</dd>
                    <dd>lien ket</dd>
                </dl>
            </li>-->
    	</ol>
	</div>
</div>
<script>
<?php
if(count($arrresultcompare) == 0) {
	echo('window.location = "'.$host.'so-sanh-the-tin-dung.html";');
} 
?>
$(document).ready(function(e) {
<?php

	for($i = 0; $i < count($arrresultcompare); $i++) {
		$hanmuc = changnumbermoney($arrresultcompare[$i][4]);
		$btranfer = changnumbermoney($arrresultcompare[$i][8]);
		$phinam = changnumbermoney($arrresultcompare[$i][11]);
		$phichamtt = changnumbermoney($arrresultcompare[$i][13]);
		$notoithieu = changnumbermoney($arrresultcompare[$i][14]);
		echo("insertrow('".$arrresultcompare[$i][0]."', '".$arrresultcompare[$i][1]."', '".$arrresultcompare[$i][2]."', '".$arrresultcompare[$i][3]."', '".$hanmuc."', '".$arrresultcompare[$i][5]."', '".$arrresultcompare[$i][6]."', '".$arrresultcompare[$i][7]."', '".$btranfer."', '".$arrresultcompare[$i][9]."', '".$arrresultcompare[$i][10]."', '".$phinam."','".$arrresultcompare[$i][12]."','".$phichamtt."','".$notoithieu."','".$arrresultcompare[$i][15]."','".$arrresultcompare[$i][16]."','".$arrresultcompare[$i][17]."');");
	}
?>
	
	function insertrow(id, bank, namebank, logo, hanmuc, ctname, ctlogo, clname, btranfer, mtranfer, rate, phinam, dayfree, phichamtt, notoithieu, phiruttienmat, khuvuc, linkgoto) {
		htmlcom = '<div class="company"><span>'+namebank+'('+bank+')</span><a class="closeproduct" title="Xóa" value="'+id+'"></a></div>';
		htmlcont = '<li id="product_'+id+'"><dl class="product-details" style="width: 200px;"><dd><img src="<?php echo($host) ?>'+logo+'" alt="'+namebank+'('+bank+')" title="'+namebank+'('+bank+')" height="36px" /></dd><dd class="colorbg">'+hanmuc+'</dd><dd><img src="<?php echo($host) ?>'+ctlogo+'" alt="'+ctname+'" title="'+ctname+'" height="36px" /></dd><dd class="colorbg">'+clname+'</dd><dd>'+btranfer+' ('+mtranfer+' Tháng)</dd><dd class="colorbg">'+rate+'%</dd><dd>'+phinam+'</dd><dd class="colorbg">'+dayfree+' Ngày</dd><dd>'+phichamtt+'</dd><dd class="colorbg">'+notoithieu+'</dd><dd>'+phiruttienmat+'</dd><dd class="colorbg">'+khuvuc+'</dd><dd><a href="'+linkgoto+'" target="_blank">Liên Kết</a></dd></dl></li>';
		
		$('.class-content-company').append(htmlcom).children(".company:last").hide().fadeIn(200);;
		$('.productlist').append(htmlcont).children(".productlist li:last").hide().fadeIn(200);;
	}
	
	$(document).on('click', '.closeproduct', function() {
		elem = $(this);
		value = elem.attr('value');
		$('.class-content-result-loading').show();
		$.ajax({
			type: "POST",
			url: "<?php echo($host) ?>control/ajaxsearchcarddetail.php",
			data:{act: 'sscom', pr: 'del', idre: value},
			dataType: "json",
			success: function(response){
				$('.class-content-result-loading').hide();
				if(response == "ok") {
					elem.parent().fadeOut(300, function() {
						elem.parent().remove();
					});
					$('#product_'+value).fadeOut(300, function() {
						$('#product_'+value).remove();
					});
				}
			}
		});
	});
});
</script>
<?php
} else {
	echo("<script>window.location = '".$host."so-sanh-the-tin-dung.html';</script>");
}
?>